//
//  YHBaseViewController.swift
//  YHSwiftProject
//
//  Created by LYH on 2018/11/5.
//  Copyright © 2018年 LYH. All rights reserved.
//

import UIKit

class YHBaseViewController: UIViewController {
  
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
    view.backgroundColor = UIColor.white
    
    self.navigationItem.leftBarButtonItem = UIBarButtonItem.init(customView: leftButton)
    self.navigationItem.rightBarButtonItem = UIBarButtonItem.init(customView: rightButton)
        
    }
//状态栏颜色
  override var preferredStatusBarStyle: UIStatusBarStyle
    {
    return .lightContent
    }
   
/**标题*/
    func setNaviTitle(naviTitle : String) -> Void
{
    self.navigationItem.title = naviTitle as String
}
    
    
/**返回*/
@objc func leftButtonClick() -> Void
{
    
  self.navigationController?.popViewController(animated: true)
}
  
/**rightClick*/
@objc func rightbuttonClick() ->Void
{
 
}
    
//懒加载返回按钮
    
    lazy var leftButton: UIButton = {
        let leftbutton = UIButton.init(frame: CGRect.init(x: 0, y: 0, width: 44, height: 40))
        leftbutton.setTitleColor(.white, for: .normal)
        leftbutton.setTitleColor(UIColor.gray, for: .highlighted)
        leftbutton.titleLabel?.font = UIFont.systemFont(ofSize: 16)
      
        leftbutton.setImage(UIImage.init(named: "navbar_icon_back"), for: .normal)
        leftbutton.setImage(UIImage.init(named: "navbar_icon_back"), for: .highlighted)
        
        //枚举就直接点出来
//        leftbutton.contentHorizontalAlignment = .left
        
        leftbutton.addTarget(self, action: #selector(leftButtonClick), for: .touchUpInside)
        
        return leftbutton
    }()
  
  //懒加载右边按钮
    lazy var rightButton: UIButton = {
        let rightbutton = UIButton.init(frame: CGRect.init(x: 0, y: 0, width: 44, height: 40))
            rightbutton.setTitleColor(.white, for: .normal)
            rightbutton.setTitleColor(.lightGray, for: .highlighted)
            rightbutton.titleLabel?.font = UIFont.systemFont(ofSize: 16)
//            rightbutton.backgroundColor = UIColor.clear
        rightbutton.addTarget(self, action: #selector(rightbuttonClick), for: .touchUpInside)
        return rightbutton
    }()
   
    /*懒加载tableview*/
    lazy var YHTableview: UITableView = {
         let tableV = UITableView.init(frame: CGRect.init(x: 0, y: 0, width: KscreenWidth, height: KscreenHeight-SafeAreaTabBarHeight), style: .plain)
         if #available(iOS 11, *)
         {
             tableV.contentInsetAdjustmentBehavior = .never
         }
         tableV.estimatedSectionFooterHeight = 0
         tableV.estimatedSectionHeaderHeight = 0
         tableV.backgroundColor = .white
         tableV.rowHeight = 90
//         tableV.delegate = self
//         tableV.dataSource = self
         tableV.showsVerticalScrollIndicator = false
         //分割线
         tableV.separatorStyle = .none
         
         return tableV
     }()
    
}
